package chen.web.user;

/**
 * 系统内置角色．包括访客角色以及管理员角色．
 * @author chen
 *
 */
public class InternalRoleProvider {
	
	private static final int GuestRoleId = 1;
	private static final int AdminRoleId = 2;
	
	private static RoleManager roleManager;
	public static void setRoleManager(RoleManager roleManager){
		InternalRoleProvider.roleManager = roleManager;
	}
	
	public static Role getGuestRole(){
		Role role = roleManager.getRole(GuestRoleId);
		if(role == null){
			throw new RuntimeException("找不到访客角色：角色id:" + GuestRoleId);
		}
		return role;
	}
	
	
	public static Role getAdminRole(){
		Role role = roleManager.getRole(AdminRoleId);
		if(role == null){
			throw new RuntimeException("找不到管理员角色：角色id:" + AdminRoleId);
		}
		return role;
	}
}
